<template>
	<div slot="reference" @click="toNotice">
		<el-badge :is-dot="isDot">
			<i class="el-icon-bell"></i>
		</el-badge>
	</div>
</template>

<script>
	import * as signalR from '@aspnet/signalr';
	import {
		getToken
	} from '@/util/auth';
	export default {
		name: "top-notice",
		data() {
			return {
				isDot: false,
				option: {},
				data: [],
			}
		},
		created() {
			this.connection = new signalR.HubConnectionBuilder()
				.withUrl('http://www.jooand.com:9005/msgHub?token=' + getToken(), {
					skipNegotiation: true,
					transport: signalR.HttpTransportType.WebSockets
				})
				.configureLogging(signalR.LogLevel.Information)
				.build();
			this.connection.on('ReceiveMessage', (message) => {
				console.log(message);
				this.isDot = true;
			});
			this.connection.start();
		},
		methods: {
			toNotice() {
				this.isDot = false;
				this.$router.push({
					path: '/user/notice'
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
</style>
